#ifndef _HTTPREQUESTHANDLER_HPP_
#define _HTTPREQUESTHANDLER_HPP_

#include "jhdefs.hpp"
#include "utils/shareptr.hpp"
using JHCPP::utils::TSharedPtr;
#include "event/basicevent.hpp"
using JHCPP::event::TBasicEvent;

NET_NAMESPACE_BEGIN

class CHTTPServerRequest;
class CHTTPServerResponse;

class CHTTPRequestHandler
{
public:
	CHTTPRequestHandler();
	virtual ~CHTTPRequestHandler();

	virtual void handleRequest(CHTTPServerRequest& request, CHTTPServerResponse& response) = 0;

private:
	CHTTPRequestHandler(const CHTTPRequestHandler&);
	CHTTPRequestHandler& operator = (const CHTTPRequestHandler&);
};


class CHTTPRequestHandlerFactory
{
public:
	typedef TSharedPtr<CHTTPRequestHandlerFactory> Ptr;

	CHTTPRequestHandlerFactory();
	virtual ~CHTTPRequestHandlerFactory();

	virtual CHTTPRequestHandler* createRequestHandler(const CHTTPServerRequest& request) = 0;

protected:
	TBasicEvent<const bool> serverStopped;

private:
	CHTTPRequestHandlerFactory(const CHTTPRequestHandlerFactory&);
	CHTTPRequestHandlerFactory& operator = (const CHTTPRequestHandlerFactory&);

	friend class CHTTPServer;
	friend class CHTTPServerConnection;
};

NET_NAMESPACE_END

#endif
